﻿#region Using Statemens
using System;
using GameBase.Screens;
using GameBase.Sprites;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using StarFox.ScreenComponents;
#endregion

namespace StarFox.Screens
{
    /// <summary>
    /// Keyboard layout screen of the game.
    /// </summary>
    public class KeyboardLayoutScreen : StarFoxScreen
    {
        #region Fields

        SpriteSheet spriteSheet;

        Rectangle dstRectKbActions;
        Rectangle dstRectKbKeys;

        #endregion

        #region Initialization

        /// <summary>
        /// Initializes a new instance of this class.
        /// </summary>
        /// <param name="screenManager">The ScreenManager that this Screen is associated to.</param>
        public KeyboardLayoutScreen(ScreenManager screenManager)
            : base(screenManager)
        {
            Name = "KeyboardLayoutScreen";
        }

        /// <summary>
        /// Called when the Screen needs to be initialized.
        /// </summary>
        public override void Initialize()
        {
            Components3D.Add(new MenuBackground(this) { Duration = TimeSpan.FromSeconds(6) });
            Components2D.Add(new SimpleMenu(this) { MenuTitle = "TITLE_KEYBOARD_LAYOUT" });

            spriteSheet = Game.Content.Load<SpriteSheet>(ContentSettings.GetAsset("MENU_SPRITES"));

            Initialize_Message();

            base.Initialize();
        }

        #region Initialize_Message

        private void Initialize_Message()
        {
            Rectangle auxRect;

            // actions
            auxRect = spriteSheet.SourceRectangle("KEYBOARD_ACTIONS");
            dstRectKbActions = new Rectangle((int)(Width * 0.098f), (int)(Height * 0.25f), (int)(auxRect.Width * Scale), (int)(auxRect.Height * Scale));
            // keys
            auxRect = spriteSheet.SourceRectangle("KEYBOARD_KEYS");
            dstRectKbKeys = new Rectangle((int)(Width * 0.348f), (int)(Height * 0.25f), (int)(auxRect.Width * Scale), (int)(auxRect.Height * Scale));
        }

        #endregion

        #endregion

        #region Draw

        /// <summary>
        /// Called when 2D content of the Screen needs to be drawn.
        /// </summary>
        /// <param name="gameTime">Time elapsed since the last call to this method.</param>
        protected override void Draw2D(GameTime gameTime)
        {
            base.Draw2D(gameTime);

            SpriteBatch.Begin();

            // actions
            SpriteBatch.Draw(spriteSheet.Texture, dstRectKbActions, spriteSheet.SourceRectangle("KEYBOARD_ACTIONS"), Color.Yellow);
            // keys
            SpriteBatch.Draw(spriteSheet.Texture, dstRectKbKeys, spriteSheet.SourceRectangle("KEYBOARD_KEYS"), Color.Red);

            SpriteBatch.End();
        }

        #endregion
    }
}
